﻿using CaffeeBuzz_WinForm.Cafe;
using CaffeeBuzz_WinForm.Factorys;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CaffeeBuzz_WinForm.BuzzMenu
{
    public abstract class Menu
    {
        public abstract Iterator CreateIterator();
        protected string name;
        protected List<Condiment> condiments; // danh sach gia vi

        /// <summary>
        /// them gia vi vao mon an
        /// </summary>
        /// <param name="condiment">ten gia vi</param>
        /// <param name="indexItem">so thu tu cua mon an</param>
        public void AddCondiments(int indexCondiment, int indexItem)
        {
            Item item = GetItem(indexItem);
            condiments[indexCondiment].Condiment_Beverage = item;
            Condiment temp = (Condiment)Factory.CreateBeverage(condiments[indexCondiment].Name);
            item = temp;
        }
        public abstract void AddItem(Item i);
        public abstract void AddItem(string name, string description, double price);
        public virtual List<Item> GetAllItem()
        {
            List<Item> l = new List<Item>();
            Iterator iterator = this.CreateIterator();
            while (iterator.HasNext())
            {
                Item i = (Item)iterator.Next();
                l.Add(i);
            }
            return l;
        }
        public virtual Item GetItem(int index)
        {
            return GetAllItem()[index];
        }
        public virtual double Price
        {
            get 
            {
                double p = 0;
                Iterator iterator = this.CreateIterator();
                while (iterator.HasNext())
                {
                    Item i = (Item)iterator.Next();
                    p += i.Price;
                }
                return p;
            }
        }
        public virtual string Name
        {
            get { return name; }
        }
    }
}
